#include "SMPPMessageReplacementTLVs.hpp"

using namespace smpp::pdu;

MessageReplacementTLVs::MessageReplacementTLVs(
const MessagePayload *nMessagePayload):_MessagePayload(0){
	if(nMessagePayload)
		_MessagePayload = new MessagePayload(*nMessagePayload);
}

MessageReplacementTLVs::MessageReplacementTLVs(
const MessageReplacementTLVs &nMessageReplacementTLVs):_MessagePayload(0){
	if(nMessageReplacementTLVs.getMessagePayload())
		_MessagePayload = new MessagePayload(
		*nMessageReplacementTLVs.getMessagePayload());
}

MessageReplacementTLVs::~MessageReplacementTLVs(){
	if(_MessagePayload)
		delete _MessagePayload;
}

void MessageReplacementTLVs::setMessagePayload(
	const MessagePayload *nMessagePayload){
	if(_MessagePayload){
		delete _MessagePayload;
		_MessagePayload = 0;
	}
	if(nMessagePayload)
		_MessagePayload = 
		new MessagePayload(*nMessagePayload);
}

const MessagePayload *
	MessageReplacementTLVs::getMessagePayload() const{
	return _MessagePayload;
}

const quint16 MessageReplacementTLVs::getLength() const{
	quint16 length(0);
	if(_MessagePayload)
		length += 4 + _MessagePayload->getLength();
	return length;
}
